package com.test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.CronExpression;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;
import org.quartz.impl.StdSchedulerFactory;

public class MyQuartzServer {
	private static Log log = LogFactory.getLog(Test.class);

	public static void main(String[] args) {
		MyQuartzServer server = new MyQuartzServer();
		try {
			server.startScheduler();
		} catch (SchedulerException ex) {
			ex.printStackTrace();
		}
	}

	protected void startScheduler() throws SchedulerException {
		
		Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
		
		JobDetail jobDetail = new JobDetail("Test",Scheduler.DEFAULT_GROUP, Test.class);
		CronTrigger cronTrigger = new CronTrigger("cronTrigger", "triggerGroup2");
		try {
			CronExpression cexp = new CronExpression("0/5 * * * * ?");
			cronTrigger.setCronExpression(cexp);
			
			} catch (Exception e) {
			    e.printStackTrace();
			}
		scheduler.scheduleJob(jobDetail, cronTrigger);
		
		scheduler.start();
	}
}
